# portmap - RPC port mapper

# Portmap is a server that converts RPC (Remote Procedure Call) program
# numbers into DARPA protocol port numbers. It must be running in order
# to make RPC calls.

description	"RPC port mapper"
author		"Steve Langasek <steve.langasek@canonical.com>"

start on (local-filesystems
          and net-device-up IFACE=lo)

expect fork
respawn

script
	if [ -f /etc/default/portmap ]; then
		. /etc/default/portmap
	elif [ -f /etc/portmap.conf ]; then
		. /etc/portmap.conf
	fi

	exec portmap $OPTIONS
end script

post-start script
	if [ -f /var/run/portmap.state ]; then
		pmap_set < /var/run/portmap.state
		rm -f /var/run/portmap.state
	fi
	mkdir -p /lib/init/rw/sendsigs.omit.d
	rm -f /lib/init/rw/sendsigs.omit.d/portmap
	ln -s /var/run/portmap.pid /lib/init/rw/sendsigs.omit.d/portmap
end script

pre-stop script
	pmap_dump > /var/run/portmap.state
end script

post-stop script
	rm -f /lib/init/rw/sendsigs.omit.d/portmap
end script
